package morning.cat;

import morning.cat.entity.User;
import morning.cat.service.UserService;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class SpringiConsumer {
    public static void main(String[] args) {

        ClassPathXmlApplicationContext context = null;
        try {
            context = new ClassPathXmlApplicationContext("applicationContext*.xml");
            context.start();

            /**
             * 远程调用
             */
            UserService userService = (UserService) context.getBean("userService");

            /**
             * 测试
             */
            User user = new User();
            user.setId(1);
            user.setName("morningCat");
            String result = userService.sayHelloToUser(user);
            System.out.println("------------------------");
            System.out.println(result);
            System.out.println("------------------------");
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (context != null) {
                context.destroy();
            }
        }


    }
}
